let globalData = getApp().globalData;
const http = (params) => {
  const token = wx.getStorageSync('token') || '';
  return new Promise((reslove, reject) => {
    wx.request({
      ...params,
      url: globalData.URL + '/api' + params.url,
      header: {
        Authorization: token
      },
      method: 'POST',
      success: (result) => {
        reslove(result.data)
        if (result.data.code == 1) {
          wx.showToast({
            icon: 'error',
            title: result.data.message,
          })
        }
      },
      fail: (err) => {
        reject(err)

      }
    })
  })
};
export default http